#ifndef _DRV_H
#define _DRV_H
/*
  author Sylvain Bertrand <digital.ragnarok@gmail.com>
  Protected by GNU Affero GPL v3 with some exceptions.
  See README at root of alga tree.
*/

enum family {
	CEDAR,
	REDWOOD,
	JUNIPER,
	CYPRESS,
	HEMLOCK,
	PALM
};

#define GPU_PAGE_SZ			4096
#define GPU_PAGE_LOG2_QWS		9
#define GPU_PAGE_MASK(gpu_addr)		((gpu_addr) & 0xfffffffffffff000)
#define GPU_PAGE_IDX(gpu_addr)		((gpu_addr) >> 12)
#define IS_GPU_PAGE_ALIGNED(gpu_addr)	(!((gpu_addr) & 0xfff))
#define VGA_RANGE_SZ			(256 * 1024)	/* 256 kB */
#define CRTCS_N_MAX			6

struct vram
{
	void __iomem *bar0;
	struct gpu_range range;
};

struct dev_drv_data
{
	struct hlist_node node;

	enum family family;

	struct atombios *atb;

	struct gpu gpu;

	unsigned crtcs_n;
	struct dce4 *dce;

	void __iomem *regs;
	size_t regs_sz;
	struct vram vram;
	struct ba ba;
	struct ucode ucode;
	struct cp cp0;

	struct irq irq;

	/* userland */
	struct cdev evergreen_cdev;
	struct device *evergreen_dev;
};

u32 rr32(struct pci_dev *dev, unsigned offset);
void wr32(struct pci_dev *dev, u32 val, unsigned offset);
#endif /* _DRV_H */
